'''
法律法规管理UI测试
'''
import pytest
from Lib.common.common_function import *
from Lib.base.page_object.low.law_add import LowAdd
from Lib.base.page_object.low.law_list import LowList
import allure
import os
from Lib.common.assert_class import AssertClass


@allure.feature("法律法规管理测试")
class TestLow:

    @classmethod
    def setup_class(cls):
        cls.driver = None
        cls.lowAdd = None
        cls.lowList = None
        cls.assertClass = None

    @allure.title('新建法律法规')
    def test_01_low_add(self, login):
        '''
        新建法律法规
        :return:
        '''
        # 获取添加法律法规对像
        TestLow.lowAdd = LowAdd(login)
        # 返回断言元素
        assert_args = self.lowAdd.low_add()
        # 调用断言类
        TestLow.assertClass = AssertClass(login)
        self.assertClass.make_assert_by_text(args=assert_args, assert_data='创建成功', context="创建法律法规")

    @allure.title('查看发送法规详情')
    def test_02_low_search_and_detail(self, login):
        '''
        新建法律法规
        :return:
        '''
        TestLow.lowList = LowList(login)
        assert_args = self.lowList.low_search_and_detail()
        # 获取断言
        self.assertClass.make_assert_by_text(args=assert_args, assert_data='查看法律法规', context="查看法律法规")

    @allure.title("查询和修改法律法规")
    def test_03_low_search_and_update(self, login):
        '''
        新建法律法规
        :return:
        '''
        assert_args = self.lowList.low_search_and_update()
        # 获取断言
        self.assertClass.make_assert_by_text(args=assert_args, assert_data='更新成功', context="查看法律法规")

    @allure.title("查询和删除法律法规")
    def test_04_low_search_and_delete(self):
        '''
        新建法律法规
        :return:
        '''
        assert_args = self.lowList.low_search_and_delete()
        # 获取断言
        self.assertClass.make_assert_by_text(args=assert_args, assert_data='删除成功', context="查看法律法规")


if __name__ == '__main__':
    pytest.main(['-v', '-s', './law_test.py'])
    # os.system(r'copy ..\config\environment.properties ..\result\environment.properties')
    # os.system('allure generate  ../result -o ../report/ --clean')
